<template>
  <div>
    <!-- 搜索 -->
    <!-- 旧件回运仓库查询-按下线工厂 -->
    <TopFilter ref="TopFilterss" :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable ref="table" :columns="columns" :params="fetchParams" :fetchapi="fetchapi" :datakey="'records'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange" :is-select-column="false">
      <template slot="controls" slot-scope="props">
        <multiuse-button type="primary" :click="exportFileBtn.bind()">导出</multiuse-button>
      </template>
    </FilterTable>
  </div>
</template>
<script>
import { getListByPage, getListForExport, newSave, piliangqiyong, piliangtingyong, excelExport, editSave,exporturl } from '@/api/claim/dealer/ReturnWhQueryFactory';
import { exportExcelFile } from '@/utils/index';
import { dictionary } from '@/utils/dictMixin';

export default {
   mixins: [dictionary],
  data() {
    return {
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: true,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      fetchapi: getListByPage,
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      dialogTitle: '选择车辆',
      visibleAdd: false
    };
  },
  created() {
  },
  methods: {
    // 导出
   async exportFileBtn() {
      let json = Object.assign({}, { CODE: 'CODE_00000193' }, this.fetchParams);
      let res = await exporturl(json);
      if (res.resultCode == 200) {
        this.$router.push('/admin/auth/oem/downloadCenter');
      }
      // getListForExport(this.fetchParams).then(res => {
      //   exportExcelFile(res.data, '旧件回运仓库查询');
      // });
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({}, this.fetchParams, val);
      console.log(val);
    },
    //搜索数据
    topFilterInitFun() {
      return [
        {type: 'INPUT', label: '工厂代码', fieldName: 'factCode', placeholder: '请输入工厂代码...', initialValue: ''},
        {type: 'INPUT', label: '工厂名称', fieldName: 'factName', placeholder: '请输入工厂名称...', initialValue: ''},
        {type: 'INPUT', label: '仓库代码', fieldName: 'whCode', placeholder: '请输入仓库代码...', initialValue: ''},
        {type: 'INPUT', label: '仓库名称', fieldName: 'whName', placeholder: '请输入仓库名称...', initialValue: ''},
        {type: 'SELECT', label: '动力形式', fieldName: 'powerType', placeholder: '请选择动力形式...', initialValue: '', itemList: this.createDictList('6008'), filterable: true}
      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {title: '动力形式',dataIndex: 'powerType', sorter: true,render: props => {return <span>{this.createDictText(props.row.powerType, '6008')}</span>;}},
        {title: '仓库名称', dataIndex: 'whName', sorter: true},
        {title: '仓库代码', dataIndex: 'whCode', sorter: true},
        {title: '工厂名称', dataIndex: 'factName', sorter: true},
        {title: '工厂代码', dataIndex: 'factCode', sorter: true},
        {title: '创建人', dataIndex: 'createdBy', sorter: true},
        {title: '创建时间', dataIndex: 'createdAt', sorter: true},
        {title: '修改人', dataIndex: 'updatedBy', sorter: true},
        {title: '修改时间', dataIndex: 'updatedAt', sorter: true}
      ];
    }
  }
};
</script>

<style lang="less" scoped></style>
